1. Field of the Invention
The present invention relates generally to image compression devices compressing image data and more particularly to MPEG (Moving Picture Expert Group) video encoders or JPEG (Joint Photographic Coding Expert Group) encoders.
2. Description of the Background Art
Recently, demand for electronic still cameras is rapidly increasing replacing cameras employing the conventional photography technique which has been utilized since the 19th century. In electronic still cameras, xe2x80x9cJPEGxe2x80x9d system is employed as data compression/decompression technique to be used at the transmission and storage of image data in order to compress the image data and reduce the data amount for efficient processing. The JPEG system is made a standard by JPEG Commission (ISO/IEC 10918-1) under the ISO (International Organization for Standardization)/IEC (International Electrotechnical Commission).
JPEG system is also called JPEG algorithm whose technical core is discrete cosine transformation (hereinafter also referred to as DCT). JPEG system is widely utilized for image data processing in systems other than electronic still cameras, such as CD-ROM (Compact Disc-Read Only Memory) systems.
As JPEG system allows the compression/decompression of video data, some of the electronic still cameras employing JPEG system have a video shooting function. These technique for carrying out compression/decompression of video data according to JPEG system is called M-JPEG (Motion-JPEG).
Now, the amount of information treated in multimedia is enormous and its content is diverse. To make the multimedia fit for practical use, high-speed processing of the information is required. For the high-speed information processing data compression/decompression technique is necessary. xe2x80x9cCMPEGxe2x80x9d system is one of such data compression/decompression techniques. The MPEG system is made a standard by MPEG Commission under ISO/IEC (SO/IECJTC1/SC29/WG11).
MPEG system is constituted of three parts. Part 1 is xe2x80x9cMPEG system partxe2x80x9d (ISO/IEC IS 11172 Part1:Systems) defining the multiplex structure and synchronization system of video data and audio data. Part 2, xe2x80x9cMPEG video partxe2x80x9d (ISO/IEC IS 11172 Part2:Video) defines the high-efficiency coding method and the format of video data. In Part 3, xe2x80x9cMPEG audio partxe2x80x9d (ISO/IEC IS 11172 Part3:Audio), the high-efficiency coding method and the format of audio data are defined.
The core of a technique employed in MPEG video part is Motion Compensated Prediction (MC) and DCT. An encoding technique employing MC and DCT in combination is called a hybrid encoding technique. In other words, one can say that MPEG system is a technique combining JPEG system with MC.
MPEG system is applicable for transmission media in general including various storage media such as video CD (Compact Disc), CD-ROM, DVD (Digital Video Disc), video tape, memory card using non-volatile semiconductor memory and so on, various communication media such as LAN (Local Area Network), and various broadcasting media (ground-based broadcasting, satellite broadcasting, CATV (Community Antenna Television)).
FIG. 11 is a block circuit diagram of a conventional electronic still camera 101 employing JPEG system.
Electronic still camera 101 includes a JPEG core circuit 102, an imaging device 103, a signal processing circuit 104, a frame buffer 105, a display 106, a display circuit 107, a memory card 108, an input/output circuit 109, data buses 110 and 111 and a control core circuit 136.
JPEG core circuit 102 includes a DCT circuit 121, a quantization circuit 122, a Huffman encoding circuit 123, a code amount counter 124, a Huffman decoding circuit 131, an inverse quantization circuit 132, an inverse DCT (IDCT) circuit 133, and RAMs (Random Access Memories) 134 and 135.
Control core circuit 136 controls each of circuits 102-111 of electronic still camera 101.
Imaging device 103, constituted of a CCD or the like, picks up an image of an object and generates an output signal. Signal processing circuit 104 generates image data per screen from the output signal from imaging device 103. Image data per screen generated by signal processing circuit 104 is transferred to one of frame buffer 105 and display circuit 107 via data bus 110.
Display circuit 107 generates an image signal from the image data per screen transferred via data bus 110. Display 106 displays the image signal generated by display circuit 107 as an object image.
Frame buffer 105, constituted of a writable semiconductor memory (SDRAM (Synchronous Dynamic Random Access Memory), for example), a DRAM (Dynamic Random Access Memory), a Rambus DRAM or the like and writes and stores the image data per screen (frame) transferred via data bus 110. The stored image data is read out per screen from frame buffer 105. The image data per screen read out from frame buffer 105 is transferred to DCT circuit 121 of JPEG core circuit 102 via data bus 110.
In JPEG core circuit 102, the image data of one screen is divided into a plurality of macroblocks defined according to the standard of JPEG system, and the compression/decompression process is carried out for each block.
Here, DCT circuit 121, quantization circuit 122 and Huffman encoding circuit 123 constitute a JPEG encoder and carry out the compression process of the image data. On the other hand, Huffman decoding circuit 131, inverse quantization circuit 132 and inverse DCT circuit 133 constitute a JPEG decoder and carry out the decompression process of the image data.
With regards to the image data corresponding to one screen read out from frame buffer 105, DCT circuit 121 takes in the image data of one screen in unit of a block, carries out a two dimensional discrete cosine transformation on the image data corresponding to one block to generate a DCT coefficient.
Quantization circuit 122 quantizes the DCT coefficient supplied from DCT circuit 121 referring to a quantization threshold value stored in a quantization table stored in RAM 134.
Huffman encoding circuit 123 carries out variable length encoding of the DCT coefficient quantized by quantization circuit 122 referring to a Huffman code stored in a Huffman table stored in RAM 135 to generate compressed image data (hereinafter referred to as a compression image data) for every screen.
Code amount counter 124 counts the code amount of the compression image data each corresponding to one screen generated by Huffman encoding circuit 123.
The compression image data generated by Huffman encoding circuit 123 is transmitted to at least one of memory card 108 and input/output circuit 109 via data bus 111. Memory card 108 is detachably mounted on electronic still camera 101 and a flash memory 108a is installed in memory card 108.
Flash memory 108a writes and stores the image data each corresponding to one screen transferred via data bus 111. On the other hand, flash memory 108a reads and transfers stored compression image data per screen to data bus 111.
Input/output circuit 109 supplies the compression image data per screen transferred via data bus 111 to an external device (such as an external display, a personal computer, a printer or the like) connected to electronic still camera 101 as an output, and transfers to data bus 111 compression image data supplied as an input from the external device.
The compression image data read out from memory card 108 or the compression image data supplied as an input via input/output circuit 109 are transferred to Huffman decoding circuit 131 of JPEG core circuit 102 via data bus 111.
Huffman decoding circuit 131 carries out variable length decoding of the compression image data per screen transferred via data bus 111, referring to the Huffman code stored in the Huffman table stored in RAM 135 to generate decompressed image data (hereinafter referred to as an decompression image data) per screen.
Inverse quantization circuit 132 inverse quantizes the decompression image data each corresponding to one screen generated by Huffman decoding circuit 131, referring to the quantization threshold value stored in the quantization table store in RAM 134 to generate a DCT coefficient.
Inverse DCT circuit 133 carries out a two dimensional discrete cosine inverse transformation on the DCT coefficient generated by inverse quantization circuit 132.
The decompression image data each corresponding to one screen after the discrete cosine inverse transformation at inverse DCT circuit 133 is transferred to frame buffer 105 via data bus 110. Then, frame buffer 105 writes and stores the image data each corresponding to one screen transferred from inverse DCT circuit 133 via data bus 110. Display circuit 107 generates an image signal from the image data each corresponding to one screen transferred from inverse DCT circuit 133 via data bus 110 and, the image signal is displayed on display 106 ask an object image.
Here, the quantization threshold value stored in the quantization table stored in RAM 134 is a determinant of a compression ratio of compression image data and the quality of a reproduced image produced by decompressing the compression image data (displayed image on display 106, a reproduced image which is reproduced after being read out from memory card 108 by the external device and a reproduced image which is reproduced on the external device connected to input/output circuit 109). The Huffman code stored in the Huffman table stored in RAM 135 is a code of variable length which is allocated to quantized DCT coefficient or the decompression image data according to an expected frequency of occurrence and a Huffman code with a shorter code length is allocated to those with higher frequency of occurrence.
The maximum value of the code amount of the compression image data corresponding to one screen generated by Huffman encoding circuit 123 is determined according to an image quality mode previously set in electronic still camera 101. This is because the number of screens (the number of photographs) which can be stored in memory card 108 has been determined by the image quality mode of electronic still camera 101. For example, the number of photographs which can be stored in memory card 108 is determined to be a few sheets in a high image quality mode and several sheets in a low image quality mode.
In the high image quality mode, the compression ratio of the compression image data is set low. Hence, the code amount for the compression image data corresponding to one screen becomes large and the number of photographs which can be stored in memory card 108 decreases. On the other hand, in the low image quality mode, the compression ratio of the compression image data is set high, leading to a small code amount for the compression image data per screen, and hence to a large number of photographs which can be stored in memory card 108.
Thus, the quantization threshold value and the Huffman code must be optimized to limit the code amount of the compression image data per screen generated by Huffman encoding circuit 123 such that the code amount is equal to or smaller than the predetermined maximum value. Here, the data amount of the image data per screen read out from frame buffer 105 (that is, the image data per screen generated by signal processing circuit 104) is constant regardless of the object image taken by imaging device 103. Therefore, the compression ratio of the compression image data generated by Huffman encoding circuit 123 is uniquely calculated for the code amount of the compression image data. The larger the code amount, the lower the compression ratio. Therefore, to set the code amount of the compression image data equal to or smaller than the predetermined maximum value, the compression ratio of the compression image data is set equal to or higher than the predetermined minimum compression ratio.
The compression ratio (code amount) of ,the compression image data is significantly affected by the combination of the quantization threshold value, the Huffman code and the object image. Hence, even when the quantization threshold values and the Huffman codes are same, there will be an enormous difference in compression ratios of the compression image data if the object images to be taken are different.
For example, when the object image is a complex subtle image like an image of a mob, the compression ratio should be set high to suppress the code amount small. On the other hand, if the object image is a simple image like an image of a sky without a single cloud on a fine day, the compression ratio must be set low to make the code amount large. Hence, to find the compression ratio of the compression image data, the compression image data must be actually generated through the compression process by circuits 121-123 constituting the JPEG encoder. It is difficult to predict the compression ratio before performing such compression process.
Thus, in the conventional electronic still camera 101, first, the quantization threshold value and the Huffman; code are set to predetermined values. Then the compression process is performed by circuits 121-123 constituting the JPEG encoder to generate the compression image data. The code amount of the compression image data is counted by code amount counter 124. If the code amount of the compression image data is equal to or smaller than the predetermined maximum value, the set quantization threshold value and the Huffman code can be regarded as optimal and determined to be actually used as the quantization threshold value and the Huffman code.
Then, the compression image data generated based on thus-determined quantization threshold value and the Huffman code are transferred to memory card 108 or input/output circuit 109 via data bus 111.
If the code amount of the compression image data is larger than the predetermined maximum value, however, the,quantization threshold value and the Huffman code are set again to values a bit higher than the predetermined value. Then the compression image data is generated again through the compression process by circuits 121-123 and the code amount of the compression image data is counted by code amount counter 124. If the resulting code amount of the compression image data is equal to or smaller than the maximum value, the newly set quantization threshold value and the Huffman code can be regarded as optimal and determined to be the actually employed quantization threshold value and the Huffman code.
If the code amount of the compression image data is still larger than the maximum value, the quantization threshold value and the Huffman code are set again to a still higher value and the compression process is performed again.
Thus, in the conventional electronic still camera 101, the compression process is repeatedly performed by circuits 121-123 constituting the JPEG encoder to optimize the quantization threshold value and the Huffman code such that the code amount of the compression image data becomes equal to or smaller than the predetermined maximum value (that is, such that the compression ratio of the compression image data becomes equal to or higher than a predetermined minimum value). Hence, the determination of the quantization threshold value and the Huffman code takes some times.
The following problems exist in conventional electronic still camera 101.
i) The compression process is repeatedly performed by circuits 121-123 constituting the JPEG encoder for the optimization of the quantization threshold value and the Huffman code. Therefore, the necessary time from the image pick-up by imaging device 103 to the storage of the compression image data into memory card 108 (hereinafter referred to as a recording latency) is lengthened by the amount of time required for the compression process.
To avoid this problem, the recording latency can previously be set short. In this case, however, the number of repeated compression process by circuits 121-123 becomes small and the quantization threshold value and the Huffman code cannot be optimized. Thus the quality of the image reproduced by the decompression of the compression image data can be deteriorated.
ii) Whenever the compression process is performed by circuits 121-123 constituting the JPEG encoder, the image data of one screen must be read out from frame buffer 105 and the image data must be transferred to DCT circuit 121 via data bus 110. In other words, every time the compression process is performed by circuits 121-123, a read access to frame buffer 105 must be made via data bus 110. Hence, the access to frame buffer 105 becomes congested and the problem ii) in combination with the above-described problem i) further increases the recording latency.
In addition, when the access to frame buffer 105 becomes congested, the performance of the access to frame buffer 105 from signal processing circuit 104 and display circuit 107 comes to be degraded.
To avoid this problem, the bus width of data bus 110 and the acceptable bus width for frame buffer can be widened or the operation thereof can be speed up. Such frame buffer 105 is, however, expensive and consumes large current. Hence increase in the cost and the current consumption of electronic still camera 101 will be incurred. Particularly, as electronic still camera 101 is driven by the battery, the increase in current consumption poses a serious problem.
A camera employing a silver chloride photography technique allows successive photo-taking as the image is recorded on a film almost simultaneously with the image pick-up. On the other hand, a user cannot take photographs continuously with electronic still camera 101 due to the required recording latency as described above, which causes frustration on the user""s side. To eliminate this inconvenience, the further reduction in recording latency has recently been sought.
The above-described problems i) and ii) may be occurred not just in the JPEG encoder but also in the MPEG encoder. As described above, MPEG system is the combination of JPEG system with MC. The MPEG encoder is formed by adding an MC circuit to the JPEG encoder (DCT circuit 121, quantization circuit 122 and Huffman encoding circuit 123). Therefore, the above-described problems i) and ii) apply to the MPEG encoder as well.
An object of the present invention is to provide an image compression device allowing a rapid and highly precise encoding of image data while setting a code amount of the encoded image data after compression to a predetermined value.
In brief, the present invention is an image compression device for compressing image data including a discreet cosine transformation circuit, a quantization circuit, a Huffman encoding circuit, a code amount counter and a control circuit.
The discreet cosine transformation circuit performs a two-dimensional discrete cosine transformation on image data constituting an image of one screen to generate a discrete cosine transformation coefficient.
The quantization circuit quantizes the discrete cosine transformation coefficient supplied from the discrete cosine transformation circuit referring to a quantization threshold value stored in a preset quantization table.
The Huffman encoding circuit performs a variable length encoding on the discrete cosine transformation coefficient quantized in the quantizaiton circuit referring to a Huffman code stored in a preset Huffman table to generate a compression image data.
The code amount counter counts a code amount of the compression image data generated by the Huffman encoding circuit.
The control circuit repeatedly performs a compression processing by the discrete cosine transformation circuit, the quantization circuit and the Huffman encoding circuit, while changing a setting of a parameter constituted of the quantizaiton threshold value and the Huffman code until the code amount of the compression image data counted by the code amount counter becomes equal to or smaller than a predetermined value, to determine an optimal version of the parameter for rendering the code amount of the compression image data equal to or smaller than the predetermined value.
The control circuit determines the optimal version of the parameter by dividing the image of the one screen into a plurality of blocks, selecting a block while changing the number of blocks to be selected from the plurality of blocks, and repeating the compression process on image data of the selected block.
According to another aspect, the present invention is an image compression device for compressing image data including an encoder and a control circuit.
The encoder compresses and encodes input image data.
The control circuit causes the encoder to process sample image data to determine an optimal version of a compression parameter for rendering a code amount of image data after the compression of an image of one screen to be compressed smaller than a predetermined value.
The control circuit divides the image of one screen to be compressed into a plurality of blocks, extracts a predetermined block from the plurality of blocks with a regularity so as to extract the block uniformly across the one screen, and generates the sample image data.
According to still another aspect, the present invention is an image compression device for compressing image data including a discreet cosine transformation circuit, a quantization circuit, a Huffman encoding circuit, a code amount counter, a Huffman decoding circuit, an inverse quantization circuit and a control circuit.
The discreet cosine transformation circuit performs a two-dimensional discrete cosine transformation on image data of one screen to generate a discrete cosine transformation coefficient.
The quantization circuit quantizes the discrete cosine transformation coefficient supplied from the discrete cosine transformation circuit referring to a quantization threshold value stored in a preset quantization table.
The Huffman encoding circuit performs a variable length encoding on the discrete cosine transformation coefficient quantized in the quantization circuit referring to a Huffman code stored in a preset Huffman table to generate a compression image data.
The code amount counter counts a code amount of the compression image data generated by the Huffman encoding circuit.
The Huffman decoding circuit performs a variable length encoding on the compression image data generated by the Huffman encoding circuit referring to the Huffman code stored in the preset Huffman table, to generate decompression image data.
The inverse quantization circuit performs an inverse quantization on the decompression image data generated by the Huffman decoding circuit referring to the quantization threshold value stored in the preset quantization table to generate a discrete cosine transformation coefficient and sends the generated discrete cosine transformation coefficient back to the quantization circuit. The quantization circuit quantizes the discrete cosine transformation coefficient sent back from the inverse quantization circuit referring to the quantization threshold value stored in the preset quantization table.
The control circuit repeatedly performs a compression processing by the quantization circuit, the Huffman encoding circuit, the Huffman decoding circuit and the inverse quantization circuit, while changing a setting of a parameter constituted of the quantizaiton threshold value and the Huffman code until the code amount of the compression image data counted by the code amount counter becomes equal to or smaller than a predetermined value, to determine an optimal version of the parameter for rendering the code amount of the compression image data equal to or smaller than the predetermined value.
According to still further aspect, the present invention is an image data compression device for compressing image data including a discreet cosine transformation circuit, a quantization circuit, a Huffman encoding circuit, a code amount counter, a Huffman decoding circuit, and a control circuit.
The discreet cosine transformation circuit performs a two-dimensional discrete cosine transformation on image data constituting an image of one screen to generate a discrete cosine transformation coefficient.
The quantization circuit quantizes the discrete cosine transformation coefficient supplied from the discrete cosine transformation circuit referring to a quantization threshold value stored in a preset quantization table.
The Huffman encoding circuit performs a variable length encoding on the discrete cosine transformation coefficient quantized in the quantization circuit referring to a Huffman code stored in a preset Huffman table to generate a compression image data.
The code amount counter counts a code amount of the compression image data generated by the Huffman encoding circuit.
The Huffman decoding circuit performs a variable length decoding on the compression image data generated by the Huffman encoding circuit referring to the Huffman code stored in the preset Huffman table, to generate decompression image data and sends the decompression image data back to the Huffman encoding circuit. The Huffman encoding circuit performs the variable length encoding on the decompression image data sent back from the Huffman decoding circuit referring to the Huffman code stored in the preset Huffman table.
The control circuit repeats a process by the Huffman encoding circuit and the Huffman decoding circuit while changing a setting of the Huffman code until a code amount of the compression image data counted by the code amount counter becomes equal to or smaller than a predetermined value, to determine an optimal version of the Huffman code for rendering the code amount of the compression image data equal to or smaller than the predetermined value.
Thus a main advantage of the present invention lies in that the rapid and highly precise encoding of the image data is allowed as the compression process is repeated for the image data of a selected block and the necessary time for the compression process can be reduced based on the optimization of the parameter compared with the case where the compression process is repeated for all image data for the image of one screen.
Another advantage of the present invention lies in that a predetermine block is selected while the number of blocks to be selected from blocks of each region is changed for each region, and the compression process is repeated for the image data of the selected block. Thus, the necessary time for the compression process can be reduced based on the optimization of the parameter compared with the case where the image for one screen is not divided into a plurality of regions, whereby the rapid and highly precise encoding of the image data is allowed.
Still another advantage of the present invention lies in that once the image data for a screen is transferred to the discrete cosine transformation circuit, the discrete cosine transformation circuit is not used at the time of determination of parameters. Hence, the necessary time for the transfer after the optimization of parameter can be reduced compared with the case where the image data of an image of one screen is transferred to the discrete cosine transformation circuit every time the process is repeated. Thus, the rapid and highly precise encoding of the image data is allowed.